<?php 
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.$module.'/common.inc.php';
if(!$CAT || $CAT['moduleid'] != $moduleid) {
	$head_title = lang('message->cate_not_exists');
	@header("HTTP/1.1 404 Not Found");
	exit(include template('list-notfound', 'message'));
}

if(!check_group($_groupid, $MOD['group_list']) || !check_group($_groupid, $CAT['group_list'])) {
	$head_title = lang('message->without_permission');
	exit(include template('noright', 'message'));
}
if($MOD['cat_property'] && $CAT['property']) {
	require DT_INC.'/property.func.php';
	$PPT = property_condition($catid);
}
unset($CAT['moduleid']);
extract($CAT);
$maincat = get_maincat($child ? $catid : $parentid, $moduleid);

$condition = '(status=3 or status=2)';
$condition .= ($CAT['child']) ? " AND catid IN (".$CAT['arrchildid'].")" : " AND catid=$catid";

if($cityid) {
	$areaid = $cityid;
	$ARE = $AREA[$cityid];
	$condition .= $ARE['child'] ? " AND areaid IN (".$ARE['arrchildid'].")" : " AND areaid=$areaid";
	$items = $db->count($table, $condition, $CFG['db_expires']);
} else {
	if($page == 1) {
		$items = $db->count($table, $condition, $CFG['db_expires']);
		if($items != $CAT['item']) {
			$CAT['item'] = $items;
			$db->query("UPDATE {$db->getPre()}category SET item=$items WHERE catid=$catid");
		}
	} else {
		$items = $CAT['item'];
	}
}
foreach($maincat as $k=>$v){
	if($v['item']!=$items){
		$conditions=str_replace("catid=$catid","catid=".$v['catid'],$condition);
		$maincat[$k]['item'] = $db->count($table, $conditions, $CFG['db_expires']);
	}
}
$tags = array();
$do   = new TrafficModule($moduleid);
if($items) {
	$tags = $do->getList($condition,$MOD['order'],($CFG['db_expires'] && $page == 1) ? 'CACHE' : '');
}
$showpage = 1;
$datetype = 5;
$cols = 5;

$seo_file = 'list';
include DT_INC.'/seo.inc.php';

$template = $CAT['template'] ? $CAT['template'] : ($MOD['template_list'] ? $MOD['template_list'] : 'list');
include template($template, $module);
?>